<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<form action="" name="searchForm2" id="searchForm2">
	<div id="highSerchContent" class="container" style="display: none;">
		<fieldset>
			<legend>楼盘信息</legend>
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
				<tr>
					<td width="6%" height="30" align="right">城区:</td>
					<td width="18%" height="30">
						<s:select id="districtId" name="districtId" list="SpecialList" listKey="entityCode" listValue="entityName" headerKey="" headerValue="请选择" theme="simple" onchange="cleanDate()"/>
					</td>
					<td width="6%" align="right">商圈:</td>
					<td width="32%">
					    <input type="hidden" id="bizAreaId_s"/>
					    <input type="text" id="bizAreaName_s" size="20" />
						<img id="bizAreaId_HigSearch_Image" style="cursor: pointer;" onclick="clickBizArea()" src="styles/highSearch/images/u96.png" />
					</td>
					<td width="6%" height="30" align="right">楼盘:</td>
					<td width="32%" height="30">
					    <input id="resblockId_s" type="hidden">
					    <input id="resblockName_s" type="text" size="20" />
					    <img id="house_1_1" style="cursor: pointer;" onclick="clickResblock()" src="styles/highSearch/images/u96.png" />
					</td>
				</tr>
			</table>
		</fieldset>
		<fieldset>
			<legend>房源信息</legend>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="11%" height="30" align="right">栋座:</td>
					<td width="14%" height="30">
						<input type="text" value="" size="8" name="buildBlock" id="buildBlock" class="iput_t6" />
					</td>
					<td width="11%" align="right">楼层:</td>
					<td width="14%">
						<input type="text" value="" size="2" name='floorMin' id='floorMin' class="iput_t2" /> - 
						<input type="text" value="" size="2" name='floorMax' id='floorMax' class="iput_t2" />
					</td>
					<td width="11%" align="right">居室:</td>
					<td width="14%">
						<input type="text" value="" name="minRoom" id="minRoom" class="iput_t2" /> - 
						<input type="text" value="" name="maxRoom" id="maxRoom" class="iput_t2" />
					</td>
					<td width="11%" align="right">面积:</td>
					<td width="14%">
						<input type="text" value="" size="2" name="minSqrt" id="minSqrt" class="iput_t2" /> - 
						<input type="text" value="" name="maxSqrt" id="maxSqrt" class="iput_t2" />
					</td>
				</tr>
				<tr>
					<td height="30" align="right">朝向:</td>
					<td height="30" colspan="3">
						<s:iterator value="%{typeList[3]}" id="typeItem">
							<s:if test='#typeItem.value=="东"||#typeItem.value=="南"||#typeItem.value=="西"||#typeItem.value=="北"'>
								<input type="checkbox" value="<s:property value='#typeItem.key' />" <s:if test="#typeItem.key.indexOf(toward)!=-1">checked="checked"</s:if> name="toward" id="toward" />
								<s:property value='#typeItem.value' />
							</s:if>
						</s:iterator>
					</td>
					<td height="30" align="right">建成年代:</td>
					<td height="30">
						<input type="text" value="" size="2" class="iput_t2" name='buildTimeMin' id='buildTimeMin' /> - 
						<input type="text" value="" class="iput_t2" name='buildTimeMax' id='buildTimeMax' /></td>
					<td height="30" align="right">建筑类型:</td>
					<td height="30">
						<i:select id="buildType" name="buildType" value="" key="1022" viewText="请选择" />
					</td>
				</tr>
				<tr>
					<td height="30" align="right">房屋用途:</td>
					<td height="30"><i:select id="usageType" name="usageType" value="" key="1075" viewText="请选择" /></td>
					<td height="30" align="right">装修现状:</td>
					<td height="30"><i:select id="fitmentType" name="fitmentType" value="" key="1121" viewText="请选择" /></td>
					<td height="30" align="right">房屋现状:</td>
					<td height="30"><i:select id="houseStatus" name="houseStatus" value="" key="1033" viewText="请选择" /></td>
					<td height="30" align="right">房源级别:</td>
					<td height="30"><i:select id="houseLevel" name="houseLevel" value="" key="1176" viewText="请选择" /></td>
				</tr>
				<tr>
					<td height="30" align="right">房屋权属:</td>
					<td colspan="7"><i:select id="propertyType" name="propertyType" value="" key="1013" viewText="请选择" /></td>
				</tr>
			</table>
		</fieldset>
		<fieldset>
			<legend>委托信息</legend>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="11%" height="30" align="right">房源编号:</td>
					<td width="14%" height="30">
						<input type="text" value="" size="7" name="houseNum" id="houseNum" />
					</td>
					<td width="11%" align="right">委托方式:</td>
					<td width="14%">
						<select name="trustType" id="trustType" class="select">
							<option value="">请选择</option>
							<s:iterator value="%{typeList[1]}" id="typeItem">
								<s:if test='#typeItem.key!=@com.homelink.sales.module.common.util.ConstantClass@DELEGATIONTYPE_rent'>
									<option value="<s:property value='#typeItem.key' />">
										<s:property value='#typeItem.value' />
									</option>
								</s:if>
							</s:iterator>
						</select>
					</td>
					<td width="11%" align="right">委托编号:</td>
					<td width="14%"><input type="text" value="" name="saleRegisterNo" id="saleRegisterNo" size="7" /></td>
					<td width="11%" align="right">总价:</td>
					<td width="14%">
						<input type="text" value="" size="2" class="iput_t2" name="sumMinMoney" id="sumMinMoney" /> - 
						<input type="text" value="" class="iput_t2" name="sumMaxMoney" id="sumMaxMoney" />
					</td>
				</tr>
				<tr>
					<td colspan="8">
						<input value="1" type="checkbox" name='isKey' id='isKey' />钥匙 
						<input value="1" type="checkbox" name='isAppro' id='isAppro' />实堪
						<input value="1" type="checkbox" name='isOnly' id='isOnly' />独家
					</td>
				</tr>
			</table>
		</fieldset>
		<fieldset>
			<table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr>
					<td width="10%" height="30" align="right" nowrap>所属区域:</td>
					<td width="25%" colspan="3">
						<input type="hidden" id="areaNo" name="areaNo" value="${areaNo}" />
						<input type="text" class="input w80" name="area" id="area" readonly value="${organization}" />
						<img src="<c:url value='/images/flowunit.gif'/>" class="imgcontrol" id="areaSelect" />
					</td>
					<td width="10%" height="30" align="right" nowrap>所属部门:</td>
					<td width="25%" colspan="3">
						<input type="hidden" id="storeNo" name="storeNo" value="${storeNo}" />
						<input type="text" class="input w80" name="organization" id="organization" readonly value="${organization}" />
						<img src="<c:url value='/images/flowunit.gif'/>" class="imgcontrol" id="orgSelect" />
					</td>
					<td width="10%" height="30" align="right" nowrap>所属人员:</td>
					<td width="25%" height="30" colspan="3">
						<input type="hidden" id="createdBy" name="createdBy" value="${createdBy}" />
						<input type="text" class="input w80" name="clerk" id="clerk" readonly value="${clerk}" />
						<img src="<c:url value='/images/flowunit.gif'/>" class="imgcontrol" id="userSelect" />
					</td>
				</tr>
				<tr>
					<td width="11%" align="right">新建日期:</td>
					<td height="30" colspan="9">
						<input ctype="text" value="" size="10" name="entrustMinDate" type="text" id="entrustMinDate" readonly /> -- 
						<input type="text" value="" size="10" name="entrustMaxDate" type="text" id="entrustMaxDate" readonly />
						<input type="button" name="search" id="search2" value="查询" class="submit_2" /> 
						<input type="button" name="reset2" id="reset2" value="重置"  class="submit_2"/>
						<input type="button" name="button2" id="button2" value="关闭" class="submit_2" />
					</td>
				</tr>
			</table>
		</fieldset>
	</div>
</form>
<script>
//选择组织和人员的预备阶段
$("#userSelect").click(function(){
	var caption = "用户选择";
	var orgIdList = "";
	if($("#storeNo").val()){
		orgIdList = $("#storeNo").val();
	}else if(!$("#storeNo").val() && $("#areaNo").val()){
		orgIdList = $("#areaNo").val();
	}
	var callback = 'userSelectCallback';
	var mutiple = false;
	//orgUserRootTreePopup(caption, callback, null, null, mutiple , 400 , 600)
	orgUserTreePopup(caption, orgIdList, null,null,null, mutiple, callback, 400, 600);
});
$("#orgSelect").click(function(){
  	var caption = "组织选择";
  	var orgIdList = "";	
  	if($("#areaNo").val()){
		orgIdList = $("#areaNo").val();
  	}
	var callback = 'orgSelectCallback';
	var mutiple = false;
 	orgTreePopup(caption, orgIdList, null, mutiple, callback, 400, 600);
});
$("#areaSelect").click(function(){
   	var caption = "区域选择";
	var orgIdList = "";
	var callback = 'areaSelectCallback';
	var mutiple = false;
    orgTreePopup(caption, orgIdList, null, mutiple, callback, 400, 600);
});
function areaSelectCallback(orgs){
	if(!orgs){
		alert("no org selectd!");
		return false;
	}
	var area = $('#area');
    var areaNo = $('#areaNo');
    area.val("");//把之前的值清掉
    areaNo.val("");//清楚以前的值
    var str = "", str1 = "", orgLevel = "";
    for(var i=0; i<orgs.length; i++){
        var user = orgs[i];
        str += user.orgName;
        str1 += user.orgId;
		orgLevel = user.orgType;
        if(i < orgs.length-1){
        	str += ",";
        	str1 += ",";
        }
    }
    //只能选择店组
    if(orgLevel == 6){
		area.val(str);
		areaNo.val(str1);
    }else{
        alert('所属部门只能选择区！');
    }
}
//以默认组织为根节点构建选人树
function userSelectCallback(users) {
    if (users==null || users.length==0) {
        alert("no user selected!");
        return false;
    }
    handleUserDatas(users);
}

//以指定组织作为根节点构建组织选择树
function orgSelectCallback(orgs) {
    if (orgs==null || orgs.length==0) {
        alert("no org selected!");
        return false;
    }
    handleOrgDatas(orgs);
}
//选择人侯调用的方法，赋值
function handleUserDatas(datas) {
	var clerk = $('#clerk');
	var createdBy = $('#createdBy');
	clerk.attr("value","");//把之前的值清掉
	var str="";
	var str1 = "";
    for (var i=0;i<datas.length;i++) {
        var user = datas[i];
        str+=user.userName;
        str1+=user.userId;
        if(i<datas.length-1){
        str1+=",";
        str+=",";
        }
    }
  
    //alert(str1);
    clerk.attr("value",str);//重新赋值
    createdBy.attr("value",str1);//重新赋值
}
//选择组织后调用的方法，选组织
function handleOrgDatas(datas) {
    var organization = $('#organization');
    var storeNo = $('#storeNo');
    organization.attr("value","");//把之前的值清掉
    storeNo.attr("value","");//清楚以前的值
    var str="";
    var str1="";
    var orgLevel="";
    for (var i=0;i<datas.length;i++) {
        var user = datas[i];
        str+=user.orgName;
        str1+=user.orgId;
		orgLevel = user.orgType;
        if(i<datas.length-1){
        str+=",";
        str1+=",";
        }
    }
    //只能选择店组
    if(orgLevel == 8){
        organization.attr("value",str);//重新赋值
        storeNo.attr("value",str1);//重新赋值Id
    }else{
        alert('所属部门只能选择店组！');
    }
}
function mySearch2(url){
	var searchClick = '1';//是点击按钮查询
 	var str = "";
 	$("input[id='bizAreaCheckId']").each(function(){
 	   	if($(this).attr('checked')){
 			str += $(this).val() + ",";//商圈
 	   	}
 	});

	var sumMinMoney = $('#sumMinMoney').val();
	var sumMaxMoney = $('#sumMaxMoney').val();
	var minSqrt = $('#minSqrt').val();
	var maxSqrt = $('#maxSqrt').val();
	var minRoom = $('#minRoom').val();
	var maxRoom = $('#maxRoom').val();
	//var floor = $('#floor').val();
	var toward = "";
 	$("input[id='toward']").each(function(){
 	    if($(this).attr('checked')){
	 		toward += $(this).val() + ",";//朝向
	 	}
 	});
	var bizArea = $("#bizAreaName_s").val(); //商圈名称
	var bizAreaId = $("#bizAreaId_s").val(); //商圈id
	if(bizArea != ""){
		bizArea = "'" + bizArea.replace(/,/g, "','") + "'";
	}
	var house = $("#resblockName_s").val(); //楼盘名称
	var resblockPkid = $("#resblockId_s").val(); //楼盘id
	if(house != ""){
		house = "'" + house.replace(/,/g, "','") + "'";
	}
	var districtId = $('#districtId').val();	
	
	var buildType = $('#buildType').val();
	var buildTime = $('#buildTime').val();
	var houseLevel = $('#houseLevel').val();
	var houseNum = $('#houseNum').val();
	var buildBlock = $('#buildBlock').val();
	var unit = $('#unit').val();
	var layer = $('#layer').val();
	var door = $('#door').val();
	var trustType = $('#trustType').val();
	var organization = $('#organization').val();
	var clerk = $('#clerk').val();
	var entrustMinDate = $('#entrustMinDate').val();
	var entrustMaxDate = $('#entrustMaxDate').val();
	var sortName = $('#sortName').val();
	var sortOrder = $('#sortOrder').val();
	var searchFlag = $('#searchFlag').val();
	var storeNo = $('#storeNo').val();
	var createdBy = $("#createdBy").val();
	var clerk = $("#clerk").val();
	
	var usageType = $("#usageType").val(); //房屋用途
	var buildTimeMin = $("#buildTimeMin").val(); 
	var buildTimeMax = $("#buildTimeMax").val(); 
	var fitmentType = $("#fitmentType").val(); 
	var saleRegisterNo = $("#saleRegisterNo").val(); 
	var houseStatus = $("#houseStatus").val();
	var propertyType = $("#propertyType").val();
	var isOnly = $("#isOnly").attr("checked") === true ? "1" : "0";
	var areaNo = $("#areaNo").val();
	var floorMin = $('#floorMin').val();
	var floorMax = $('#floorMax').val();
	var isAppro =""; 
	$("input[id='isAppro']").each(function(){
 	    if($(this).attr('checked')){
	 		isAppro =1;//有实堪
	 	}
 	});
	
	var isKey = ""; 
	$("input[id='isKey']").each(function(){
 	    if($(this).attr('checked')){
	 		isKey =1;//有钥匙
	 	}
 	});
	//BUG 8383 限制"商圈"、"楼盘"、"总价/月租"三个条件至少要选择一个条件
	var checkNull = '${checkNull}';
	if(checkNull != "no" || checkNull == ""){    //判断不是只有全部房源才提示这几项不能为空
		if(!houseNum && !bizArea && !house && !sumMinMoney && !sumMaxMoney){
			alert("房源编号、总价、楼盘、商圈至少有一项不能为空！");
			return false;
		}
	}
	$("#highSerchContent").hide();

	$('#listHouseInfoAjax').jqGrid('setGridParam', {postData:null});
	$('#listHouseInfoAjax').jqGrid('setGridParam', {url:url,page:1,postData:{districtId:districtId,isAppro:isAppro,houseStatus:houseStatus,usageType:usageType,buildTimeMin:buildTimeMin,buildTimeMax:buildTimeMax,fitmentType:fitmentType,isKey:isKey,saleRegisterNo:saleRegisterNo,sumMinMoney:sumMinMoney,sumMaxMoney:sumMaxMoney,minSqrt:minSqrt,maxSqrt:maxSqrt,minRoom:minRoom,maxRoom:maxRoom, toward:toward,bizArea:bizArea,house:house,buildType:buildType,buildTime:buildTime,houseLevel:houseLevel,houseNum:houseNum,buildBlock:buildBlock,unit:unit,layer:layer,door:door,trustType:trustType,organization:organization,clerk:clerk,entrustMinDate:entrustMinDate,entrustMaxDate:entrustMaxDate,sortName:sortName,sortOrder:sortOrder,searchFlag:searchFlag,bizAreaId:bizAreaId,storeNo:storeNo,createdBy:createdBy,clerk:clerk,searchClick:searchClick, areaNo:areaNo, propertyType:propertyType, isOnly:isOnly, floorMin:floorMin, floorMax:floorMax}}).trigger('reloadGrid');
	$("#bizCirclePkid").val("");
	$("#bizAreaId").val("");
	$("#bizHousePkid").val("");
	$("#house1").val("");
	$("#buildBlock1").val("");
	$("#minRoom1").val("");
	$("#maxRoom1").val("");
	$("#houseNum1").val("");
	return true;
}
</script>